Fitness Cost

In my newts and snakes simulation the phenotypes of both of the populations keeps increasing forever. In the spatial simulations this increase eventually leads to the death of one of the species and the collapses of the SLiM simulation (something I currently calculate needs to have individuals). To have my simulation run essentially forever I wanted to add in a cost to having a high phenotype.

Too come up with a cost curve I thought about the biology behind the existence of a fitness cost in the context of newts and snakes. In snakes for every mutation that allows for them to be resistant to the toxin they partially break their mobility. So snakes become slower when they are more resistant and can be preyed upon by other predators. Newts are a bit more complicated. It is unknown if there is a fitness cost for being more toxic. Maybe producing toxin makes them slower, maybe it takes more energy to produce so there is less energy for offspring.

Here is an example of what I think a fitness cost might look like (values are not realistic). As the phenotype gets larger the phenotype has a higher cost. So to keep a high cost phenotype there needs to be strong selection. The graph below is my initial idea on how fitness cost in my system should work.

I chose a phenotype of 3 to be half as good (this might be a tad too strong). I chose the value 3 because of the phenotypes of newts and snakes seen in the Brodies map. To calculate cost I need to look at the fitness scaling (between 0 and 1) and make my chosen phenotype meet the line at half of the total fitness (0.5).

Fitness scaling = e^-cost

If a phenotype of 3 is half the total fitness the cost would be log 2

c(p) = (a/b)^2 c(3) = (a/b)^2 log(2) = (a/b)^2 b = 3/log(2) = 10

SO cost = (phenotype/10)^2

Special Note Phenotype is arbitrary (scale for the snakes resistance)

A cost would push the phenotypes back towards 0, but would also make it harder to observe selection. I ran one simulation with the cost once and the phenotypes just keep decreasing (math version will be presented later). The simulation ran for a long time (5000 generations) and the population size did not explode or decrease. Is it possible for the phenotypes to be completely pushed back to 0? Are non-zero phenotypes a sign of poitive selection (especially if they started above 0)? Do we still see spots were coevolution is happening? Should I change the slope of the cost curve?

Dataframe and Graphs

I use the same method for building my dataframes and figures as I did in the nospace R markdown. My general theme is to make my figures and data frames reusable from simulation to simulation and from one variable to the next. It might be helpful to write some more information about each of the functions that I use.

Simulations

I ran a spatial antagonistic co-evolution simulation with a fitness cost. Both newts and snakes had the same mutation rate, mutation effect sizes and fitness costs. Here, fitness cost remained the same between all of the simulations, but the mutation rate and mutation effect size differed. I ran about 100 simulations to get a general idea of what might be happening in the simulations. I wanted to focus on what was happening to the phenotype of newts and snakes, while also observing other factors that I looked at in previous rmarkdowns (beta, phenotype differences, population sizes, ect).

Exploring the Change in Phenotypes

Here, I am looking at how the phenotypes of newts and snakes change from what they began at and what the ended at for all of the simulations that I ran. In all of the simulation the mean phenotype of the newts and snakes started out higher and after 5,000 generations it dropped. The phenotypes did not become 0. I kind of want them to hang out around 3. I wonder what would happen to the newt and snake phenotype if I kept the simulation running?

I also graphed the newt and snake phenotype by generation for all of simulations. The typical trend that I saw was that the newt/snake phenotype would drop quickly then level out (it might be lowering slowly, but thats difficulat to tell).

When looking at the variation between the simulations for the mean phenotypes and the standard deviation I saw that the simulations seemed to match each other. There was little variation between the simulations. Is it possible for the interaction of selection and cost to make the newt and snake phenotypes more similar between simulations? Can the selection coef. be determined from these results?

## Warning: Removed 1 rows containing non-finite values (stat_boxplot).

The Difference Betwwen Snake and Newt Mean Phenotype

As I have seen in most of my newt and snake simulations the difference between snake and newt mean phenotype was small. With the addition of a phenotype cost I see less simulations where either the newt or snake has a higher phenotype. Here, there are two simulations that show this happening. Does adding a cost keep one of the species from escaping the interaction?

Interaction Between Polulation Factors and Phenotype

In this section I look at the interaction between population factors such as population size and the amount of newts and snakes killed and the phenotype of the newts and snakes. I will also try to compare these results to my simulations without cost.

When I plotted the difference between mean phenotype and deaths/age I saw a square blob. There are too many points that were plotted on-top of each other to see a trend. A possible trend is that when the snake mean phenotype is higher more newts are dying. When the newt phenotype is higher there might be more snakes dying. This result is not what I saw in my other spatial simulation, it is more like what I saw in my nospace simulations. Why would this be occuring? I also saw a really weird interaction between population size and phenotype. When the snake phenotype was higher there were more newts and when the newt phenotype was higher there were more snakes. This is the exact opposite from what I had been seeing in the spatial and nospace simulations. Why would adding a cost to phenotypes be causing these patterns? Maybe, if the snake phenotype was higher then there would be more snakes, except that if the phenotype was higher there would be a cost lowering the amount of snakes. Maybe this does make sense. If newts or snakes had a high phenotype then there fitness would be lower which could lower the population size.

I also made my favorite whale plots! Except here I see the higher phenotype for a particular species when their population size is lower. I wonder if this is because of the interaction between newts and snakes and the cost of the phenotype. For example, maybe there are a lot of newts and they are interaction with snakes the only snakes to survive this interaction are snakes with a higher phenotype. The snakes have a higher phenotype are less fit so they reproduce less. I also saw a lot more in-between points where both the populations of newts and snakes were not large. The patter looks more like a hump and less like a curve.

Beta Value and Other Comparisons

I am currently working on a better way to measure the correlation between phenotype and fitness (beta). However, this is the old way that I have been measuring beta (which is for the whole population). The problem with this way of measuring beta is that ther migh be some area with a higher beat and areas with a lower beta which should cause the beta for the would population to be close to 0.

So, when I plotted my beta values I was nor surprised to seem them clustered around 0. Beta does look to be slightly more negative. Could this be due to cost or is it just random chance?

The green eyeball of newt beta by snake beta values is centered around zero with a quite a few additional points neagtive for both the newts and the snakes.

## Warning: Removed 1 rows containing missing values (geom_point).

In the last set of figures I was surprised to see that beta values were very negative at the beginning of my simulation. This reflects on how quickly the newt and snake phenotype dropped in the beginning of the simulations. In the other three figures I did not notice any specfic patter or trend. It looks like a blob when looking at the difference between snake and newt phenotype vs age or beta. It also looks like a blob in the figure which plots newt mean phenotype by snake mean phenotype.

## Warning: Removed 1 rows containing missing values (geom_point).

## Warning: Removed 1 rows containing missing values (geom_point).

Extra thoughts on different values for cost

Right now the phenotype of newts and snakes goes down due to fitness cost. However, the mean phenotype of snakes and newts does not go down to 0. This result might indicate that there is a benefit for having a costly phenotype. I think the cost value I picked is too high in this case.

Original choice is 10 phenotypes dropped to ~0.3 Next choice is 100 phenotypes hold around 2-3?

For this experiment I tested different cost values (exp(-(‘pheno’/cost_value)^2. The main question I asked was, what would phenotypes be like if my cost-value was set at 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, and 200? I want to look at the mean and standard deviation of the newt and snake phenotypes between these simulations.

I run one cost1on1 simulation per cost value. Each of these simulations start out with the same msprime file and run on different seeds.

Here I looked at the mean, sd, max, and min of newts and snakes phenotypes at every 20 generations (dots would be more accurate but lines are easier to see in this case). Each line is a simulation that I ran at a certain cost value. These cost values when from 10 to 200. It looks like the higher I set the cost value the larger the mean phenotype gets and stays. I also noticed that the standard deviation and maximum phenotype got larger as the cost value got larger. The minimum phenotype also seemed to get larger as the cost value was increased, but it varied a lot and looked to have been near or at 0 is some of the simulations. I feel like some of the max phenotypes for the newts and snakes are really high at some points in the simulations (occurring when the cost value is high). It seems like the higher the cost value (which is similar to the phenotype of half fitness?) the larger and more variable the phenotype of newts and snakes gets.

At Different Costs do the Mean Phenotpyes Still Match?

My next thoughts in this experiment fell on the interaction between newts and snakes. To see if the newts and snakes are interacting I looked at the difference between the mean snake phenotype and the mean newt phenotype. This will (hopefully) show me that newts and snake phenotypes are similar and thus they are competing. In other words one of the species phenotype is not so high that the other species cannot compete. However, I would like to not that for each of these simulations I ran only one copy to get a general sence of what might be happing when the cost value was changed.

From this figure I looked at the difference between snake and newt mean phenotype over 5000 generations (data gathered every 20 gens). Each line is a simulation that I ran at a certain cost value ranging from 10 to 200. For the most part the two phenotypes remained close to each other. When the cost values are smaller the phenotype of newts and snakes is smaller and then the difference between them is smaller. When the cost value was higher then the difference between snake and newt phenotypes was higher. I liked how there were times in this simulation where it seems like newts are winning (negative values) and then in the smae simulation snakes seem to be winning (positive values). Maybe some evidence of a phenotype cycling?